package com.ponhu.ea2.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ponhu.ea2.annotations.EnableColumnChangeLog;
import com.ponhu.ea2.annotations.OperationRecordId;
import com.ponhu.ea2.constants.CommonConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

@Data
@Accessors(chain = true)
@ApiModel(value = "货品编辑-数据传输模型 ")
public class PhInventoryDetailEditDto extends OperatorDto {

    @NotNull(message = "货品ID不可为空")
    @ApiModelProperty(value = "货品ID", required = true)
    @OperationRecordId(businessTable = CommonConstant.BUSINESS_TYPE_INVENTORY)
    private Long inventoryId;

    @NotEmpty(message = "货品名称不可为空")
    @ApiModelProperty(value = "货品名称", required = true)
    @EnableColumnChangeLog(columnDesc = "货品名称")
    private String inventoryName;

    @ApiModelProperty(value = "成色字典值", required = true)
    private Integer quality;

    @ApiModelProperty(value = "成色中文名称", required = true)
    @EnableColumnChangeLog(columnDesc = "成色中文名称")
    private String qualityValue;

    @ApiModelProperty(value = "鉴定师ID", required = true)
    private Integer appraiserId;

    @ApiModelProperty(value = "鉴定师", required = true)
    @EnableColumnChangeLog(columnDesc = "鉴定师")
    private String appraiserName;

    @NotEmpty(message = "原产地不可为空")
    @ApiModelProperty(value = "原产地", required = true)
    @EnableColumnChangeLog(columnDesc = "原产地")
    private String provenance;

    @ApiModelProperty(value = "年份")
    @EnableColumnChangeLog(columnDesc = "年份")
    private String year;

    @ApiModelProperty(value = "瑕疵", required = true)
    @EnableColumnChangeLog(columnDesc = "瑕疵")
    private String flaw;

    @ApiModelProperty(value = "备注")
    @EnableColumnChangeLog(columnDesc = "备注")
    private String remarks;

    @ApiModelProperty(value = "货品附件集合")
    private List<PhInventoryAccessoryDto> annexList;

    @JsonIgnore
    @ApiModelProperty(value = "货品附件", hidden = true)
    @EnableColumnChangeLog(columnDesc = "货品附件")
    private String annexs;

    @ApiModelProperty(value = "货品配件集合")
    private List<PhInventoryAccessoryDto> accessoryList;

    @JsonIgnore
    @ApiModelProperty(value = "货品配件", hidden = true)
    @EnableColumnChangeLog(columnDesc = "货品配件")
    private String accessories;

    @ApiModelProperty(value = "货品属性集合")
    private List<PhPropertyValueDto> porpList;

    @JsonIgnore
    @ApiModelProperty(value = "货品属性", hidden = true)
    @EnableColumnChangeLog(columnDesc = "货品属性")
    private String porps;

    @NotEmpty(message = "货品详细图不可为空")
    @ApiModelProperty(value = "货品详细图")
    @EnableColumnChangeLog(columnDesc = "货品详细图")
    private String detailImage;

    @ApiModelProperty(value = "包小检识图ID")
    @EnableColumnChangeLog(columnDesc = "包小检识图ID")
    private String itemId;

    @ApiModelProperty(value = "包小检识图结果")
    private String bxjAiJson;

    public String getInventoryName() {
        if (StringUtils.isNotBlank(inventoryName)) {
            return inventoryName.trim();
        } else return inventoryName;
    }

    public void setInventoryName(String inventoryName) {
        if (StringUtils.isNotEmpty(inventoryName))
            inventoryName = inventoryName.trim();
        this.inventoryName = inventoryName;
    }

    public String getFlaw() {
        if (StringUtils.isNotBlank(flaw)) {
            return flaw.trim();
        } else {
            return null;
        }
    }

    public String getRemarks() {
        if (StringUtils.isNotBlank(remarks)) {
            return remarks.trim();
        } else {
            return null;
        }
    }

}
